<?php
namespace frontend\widgets\tag;
/**
 * 标签云
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/1/24
 * Time: 23:39
 */
use common\models\TagsModel;
use Yii;
use yii\bootstrap\Widget;

class TagWidget extends Widget
{

    public $title = '';

    public $limit = 20;

    public function run()
    {
        $res = TagsModel::find()
            ->orderBy(['post_num'=>SORT_DESC])
            ->limit($this->limit)
            ->all();

        $result['title'] = $this->title?:'标签';
        $result['body'] = $res?:[];

        return $this->render('index',['data'=>$result]);

    }
}